package operation;

import book.Book;
import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-10
 * Time: 16:33
 */
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请输入要查找的书名：");
        String name = scanner.nextLine();
        int size = bookList.getUserSize();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getPos(i);
            if(name.equals(book.getName())){
                System.out.println("找到了要查找的书，信息入下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("查无此书");
    }
}
